<template lang="pug">
div
  .ui.form(style="width: 300px; margin: 0 auto;")
    .field
      label 手机
      input(type='text', name='username', v-model="phone" )
    .field
      label 密码
      input(type='password', name='password', v-model="password", @keyup.enter="submit")
    button.ui.button(@click="submit") 登录
</template>

<script>
import { logIn } from '../../vuex/action'

export default {
  name: 'login',
  vuex: {
    getters: {},
    actions: {
      logIn,
    }
  },
  data () {
    return {
      phone: null,
      password: null,
    }
  },
  methods: {
    submit () {
      catchError(async () => {
        await this.logIn({
          phone: this.phone,
          password: this.password,
        })
        this.$router.go({name: 'index'})
      }, '登录成功')
    },
  },
}
</script>

<style lang="sass" scoped>
</style>
